﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Mvc;

namespace MyMVCDemo.Models.ViewModels.Account
{

        /// <summary>
        /// 用户注册模型
        /// </summary>
        public class RegisterModel
        {
        //todo 限制不能重复
        [Remote(action: "CheckIfNickNameIsNotUsed", controller: "Account")]
        [Required(ErrorMessage = "必填项")]
            [MaxLength(50, ErrorMessage = "长度限制为50")]
            public string 昵称 { get; set; }


            [Required(ErrorMessage = "必填项")]
            [DataType(DataType.Date)]//时间格式
            public DateTime 生日 { get; set; }



            [Required(ErrorMessage = "必填项")]
            [UIHint("GenderSelector")]  //restrict two kinds of gender 
            public string 性别 { get; set; }



            //to do 格式检

            [RegularExpression(
              pattern: @"^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$",
              ErrorMessage = "请输入正确的邮箱格式")]
            [Required(ErrorMessage = "必填项")]

            public string 邮箱 { get; set; }



            [Required(ErrorMessage = "必填项")]
            [DataType(DataType.Password)]
            [MaxLength(50, ErrorMessage = "长度限制为50")]

            public string 密码 { get; set; }



            [Required(ErrorMessage = "必填项")]
            [Compare(otherProperty: "密码", ErrorMessage = "两次密码必须一致")]  //比较两次输入字符串
            [MaxLength(50, ErrorMessage = "长度限制为50")]
            [DataType(DataType.Password)]

            public string 确认密码 { get; set; }

        }
    }
                                 
